package com.jiumozhi.spring.annotation.process;

import com.jiumozhi.spring.annotation.Student;
import com.jiumozhi.spring.annotation.bean.BeanDefinitionTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.stereotype.Component;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/1/15 11:05
 * @since JDK 1.8
 */
//@Component
public class BeanFactoryProcessorTest implements BeanFactoryPostProcessor
{

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
	{
		System.out.println("============= BeanFactoryProcessorTest invoke beanFactory =========");

		// 新增一个对象


		System.out.println("============= 新建一个对象 =========");
		beanFactory.registerSingleton("student",new Student ());

		// 获取对象,并且修改
		Student student = (Student) beanFactory.getBean("student");

		student.setName("lisi");


	}
}
